#include "summatortest.h"
#include <QtTest/QtTest>

SummatorTest::SummatorTest(QObject *parent) :
    QObject(parent)
{
    m_sum = new Summator(this);
}

void SummatorTest::testSetA()
{
    m_sum->setA(15);
    m_sum->m_b = 10;
    QCOMPARE(m_sum->sum(), 25);
}

void SummatorTest::testSetB()
{
    m_sum->m_a = 5;
    m_sum->setB(10);
    QCOMPARE(m_sum->sum(), 15);
}

void SummatorTest::testValueChanged()
{
    QSignalSpy spy(m_sum, SIGNAL(valueChanged()));
    int old = spy.count();
    m_sum->setA(5);
    m_sum->setB(10);
    QCOMPARE(spy.count() - old, 2);
}
